from django.db import models

class Source(models.Model):
    name = models.CharField(maxlength=100, unique=True)
    
    class Admin: pass

    def __str__(self):
        return self.name

class Article(models.Model):
    title = models.CharField(maxlength=200)
    link = models.URLField(unique=True)
    description = models.TextField(help_text="Use raw HTML.")
    pub_date = models.DateTimeField()
    source = models.ForeignKey(Source)    

    class Admin:
        ordering = ('-pub_date',)       
        list_display = ('title', 'source', 'pub_date')

    def __str__(self):
        return self.title

class Photo(models.Model):
    title = models.CharField(maxlength=100)
    link = models.URLField()
    source = models.ForeignKey(Source)
    pub_date = models.DateTimeField()

    class Admin: 
        list_display = ('title', 'link', 'source', )

    def __str__(self):
        return self.title
    

